# -*- coding: utf-8 -*-
# @Time    : 2023/6/5 9:49
# @Author  : hyh
# @Email   : 935887145@qq.com
# @File    : sharing_food_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from appium import webdriver
from tools import driver
from appium.webdriver.common.mobileby import MobileBy as By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import  expected_conditions as EC

class SharingFoodPage(BasePage):
    works_locator = (By.XPATH,'//*[@text="作品 0"]')
    share_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/profile_empty_recipe_header_create_recipe_btn"]')
    picture_locator =(By.XPATH,'//*[@resource-id="com.xiachufang:id/recyclerview"]/android.widget.RelativeLayout[2]')
    next_step_loator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/tv_next_step"]')
    label_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/create_dish_tag_recycler_view"]/android.widget.FrameLayout[1]')
    input_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/dish_desc"]')
    send_locator =(By.XPATH,'//*[@resource-id="com.xiachufang:id/dish_upload"]/android.widget.FrameLayout[1]')
    huoqu_text_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/navigation_bar_title_layout"]')
    def works(self):
        self.find_element(self.works_locator).click()    #点击作品按钮
    def share(self):
        self.find_element(self.share_locator).click()    #点击分享美食按钮
    def choose_picture(self):
        self.find_element(self.picture_locator).click()  #点击图片
    def next_step(self):
        self.find_element(self.next_step_loator).click() #点击下一步
    def input(self,nr):
        self.find_element(self.input_locator).send_keys(nr) #输入框输入内容
    def label(self):
        self.find_element(self.label_locator).click()    #点击标签
    def send(self):
        self.find_element(self.send_locator).click()     #点击发送按钮
    def get_text(self):
        current_text = self.find_element(self.huoqu_text_locator).get_attribute('text') #获取文本内容
        return current_text
